/**
 * 
 */
package com.gmail.blackdog1987.carcare.web.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gmail.blackdog1987.carcare.service.ConfigService;
import com.gmail.blackdog1987.carcare.util.ErrorCode;
import com.gmail.blackdog1987.carcare.web.dto.JsonResult;

/**
 * 
 * @author 董国超
 *
 */
@Controller
public class ConfigController extends BaseController {
	@Autowired
	private ConfigService configService;
	
	@ResponseBody
	@RequestMapping(value="config", method=RequestMethod.POST)
	public JsonResult config(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = configService.getAll(filter);
		if(!ErrorCode.NO.equals(result.get("code").toString())){
			return new JsonResult(Boolean.FALSE, result.get("code").toString(), result.get("msg")==null?"":result.get("msg").toString(), null);
		}
		return new JsonResult(Boolean.TRUE, result.get("result"));
	}
}
